package com.ithei.多线程第二天.可见性;

public class Money {
    public  static int money=10000;
}
//CPU
class Demo1 extends Thread{
    @Override
    public void run() {

        while (Money.money==10000){
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("money不是10000了...............");
    }
}

class  Demo2 extends Thread{
    @Override
    public void run() {
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Money.money=9000;

    }
}


class Test1{
    public static void main(String[] args) {
        Demo1 demo1=new Demo1();
        Demo2 demo2=new Demo2();
        demo1.start();
        demo2.start();
    }
}























